<template>
  <div>
    <h1>姓名:{{name}},年龄:{{age}},次数:{{num}}</h1>
    <Button type="primary" @click="add(1)">num + 1</Button>
     <Button type="primary" @click="addAsync(5)">numAsync + 5</Button>
  </div>
</template>

<script>
// import * as publicHttp from "../http/public.js";
// import myStore from '../store/stores.js';
export default {
  data() {
    return {
      postBody: {
        pageIndex: 1,
        pageSize: 10,
        sFundStatus: "fashjjlx",
        sFundCategory: "",
        sBank: "",
        sCreator: "",
        sPmName: "",
        sFullName: "",
        sFundCode: "",
        sIsRegisterChg: ""
      }
    };
  },
  created() {
    // this.list();
  },
  mounted(){
    console.log(myStore.state.age)
  },
  computed:{
    name: ()=>{
      return myStore.state.name;
    },
    age: ()=>{
      return myStore.getters.getAge;
    },
    num: ()=>{
      return myStore.state.num;
    }
  },
  methods: {
    list() {
      publicHttp.list().then(
        function(res) {
          console.log(res);
          console.log(res.data);
        },
        function(res) {
          console.error(res);
        }
      );
    },
    add(value){
      myStore.commit('changeNum',value);
    },
    addAsync(value){
      myStore.dispatch('changeNumAsync',value);
    }
  }
};
</script>

<style scoped>
div {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>